<template>
	<view class="content">		
		<view>mqtt 测试</view>
	</view>
</template>

<script>
	import mqtt from "../../utils/mqtt.js"
	const paho = mqtt();	
	
	var client = new paho.Client("wss://emqx.somedomainname.com:8084/mqtt", "clientId");
		console.log(client);

		// // set callback handlers
		client.onConnectionLost = onConnectionLost;
		client.onMessageArrived = onMessageArrived;

		// connect the client
		client.connect({ onSuccess: onConnect });


		// called when the client connects
		function onConnect() {
			// Once a connection has been made, make a subscription and send a message.
			console.log("onConnect");
			client.subscribe("test");
			let message = new paho.Message("ojbk======================");
			message.destinationName = "test";
			client.send(message);
		}

		// called when the client loses its connection
		function onConnectionLost(responseObject) {
			if (responseObject.errorCode !== 0) {
				console.log("onConnectionLost:" + responseObject.errorMessage);
			}
		}

		// called when a message arrives
		function onMessageArrived(message) {
			console.log("onMessageArrived:" + message.payloadString);
		}
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {

		},
		methods: {

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
